package net.miranti.opmov.client;

import com.google.gwt.event.shared.HandlerManager;
import com.google.inject.Inject;

import net.miranti.client.AbstractPlaceManager;
import net.miranti.opmov.events.SetupEvent;
import net.miranti.opmov.events.StartupEvent;

public class PlaceManager extends AbstractPlaceManager{
	@Inject
	public PlaceManager(HandlerManager eventBus, 
			OpMovPresenter presenter) {
		super(eventBus);
	}

	@Override
	public void go(String token) {
		TokenParser tp = new TokenParser(token);

		if(tp.key.isEmpty())
			eventBus.fireEvent(new StartupEvent());
		else {
			String a = tp.getParameter("a");
			Integer s = tp.getInteger("s");
			Integer v = tp.getInteger("v");
			Integer p = tp.getInteger("p");
			
			eventBus.fireEvent(new SetupEvent(a, s, v, p));
		}
	}
}
